<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title>AWSECommerceService</title>
	
	<script type="text/javascript" src="AWSECommerceService.js"></script>
	
	<script type="text/javascript" charset="utf-8">
    // Função responsável por inserir linhas na tabela
    function inserirLinhaTabela(id, myArray) {

        // Captura a referência da tabela com id “minhaTabela”
        var table = document.getElementById(id);
        // Captura a quantidade de linhas já existentes na tabela
        var numOfRows = table.rows.length;
        // Captura a quantidade de colunas da última linha da tabela
        var numOfCols = table.rows[numOfRows-1].cells.length;

		if (numOfCols != myArray.length) throw new Error(500, "quantidade de parametros errada" );
        // Insere uma linha no fim da tabela.
        var newRow = table.insertRow(numOfRows);
	
        // Faz um loop para criar as colunas
        for (var j = 0; j < numOfCols; j++) {
            // Insere uma coluna na nova linha 
            newCell = newRow.insertCell(j);
            // Insere um conteúdo na coluna
            newCell.innerHTML = myArray[j];
        }

    }
    
	function buscaLivro()
	{
		alert(Schema.getAAttr("Fitments").getName());
//		var par = Schema.getAAttr("Fitments");
//		alert(par.getAAttr("FitmentAttributes").getName());
//		alert(par.getAAttr("Fitment").getName());
//		body.AWSAccessKeyId = "AKIAJQUXXTU6DNW7GVAA";-->
//		body.SubscriptionId = "texto";-->
//		body.Request.SearchIndex = "Books";-->
//		body.Request.Keywords = document.frm_search.search.value;-->
//		AWSECommerceService.ItemSearch (body, WebResponse);

	}
	
	WebResponse = function (body) {
		try {
			for (var i=0 ; i < body.Items.Item.length; i++)
				addRowInnerHTML('Tabela_Resultado',body.Items.Item[i].ItemAttributes.Title);
		}
		catch (ex) {alert("No book matches the request.");}
		
		
}

	Consultar = function () {

	var parameters = Schema.getAAttr("ConsultaCEP");
	parameters.getAAttr("CEP").setValue(document.getElementById("CEPText").value);
//1ª		
//	var teste = new Elements();
//	Schema.getAAttr("InvertStringCase").getAAttr("sAString").setValue(document.getElementById("TextCasingText").value);
//	alert(Schema.getAAttr("InvertStringCase").getAAttr("sAString").getValue());
//2a
//	Elements.schema.getAAttr("InvertStringCase").getAAttr("sAString").setValue(document.getElementById("TextCasingText").value);
//	alert(Elements.schema.getAAttr("InvertStringCase").getAAttr("sAString").getValue());
			
	CEPWebService.CEPWebServiceSoap.ConsultaCEP (parameters, ConsultaResposta);
	}		
	
	ConsultaResposta = function (parameters) {
		myArray = [];
		myArray.push(parameters.getAAttr("ConsultaCEPResult").getAAttr("CEP").getValue());
		myArray.push(parameters.getAAttr("ConsultaCEPResult").getAAttr("Logradouro").getValue());
		myArray.push(parameters.getAAttr("ConsultaCEPResult").getAAttr("TipoLogradouro").getValue());
		myArray.push(parameters.getAAttr("ConsultaCEPResult").getAAttr("Bairro").getValue());
		myArray.push(parameters.getAAttr("ConsultaCEPResult").getAAttr("Cidade").getValue());
		myArray.push(parameters.getAAttr("ConsultaCEPResult").getAAttr("UF").getValue());
		myArray.push(parameters.getAAttr("ConsultaCEPResult").getAAttr("Mensagem").getValue());
		myArray.push(parameters.getAAttr("ConsultaCEPResult").getAAttr("Status").getValue());
		inserirLinhaTabela("CEPTable", myArray);
	}
	
	</script>
	
</head>

<body>
	<form action="" accept-charset="utf-8">
		<fieldset>
			<input type="text" name="AmazonText" value="" id="AmazonText"/>	
			<input type="button" value="Continue &rarr;" onclick="buscaLivro()"/>		
		</fieldset>

		
	</form>

	<div class="AmazonConteudo">
		<table id="AmazonTable" border="1">
		
				<tr>
					<th>Nome</th>
				</tr>	
		</table>
	</div>	
	
</body>
</html>